/**

   net_server.h
   ============
	
   generic server header
	
**/


#ifndef NET_SERVER_H
#define NET_SERVER_H
 

/**

   Includes
   --------
	
   - pthread.h    : threads
	
**/

#include <pthread.h>



/**

   Typedef: req_handler
   --------------------
	
   Typedef for network request handler
	
**/

typedef	void req_handler(int);



/**

   Structure: struct net_server
   ----------------------------

   Net server

**/


struct net_server
{
  unsigned short port;
  int queue;
  int socket;
  unsigned int nthreads;
  pthread_t* threads;
  pthread_mutex_t lock;
  req_handler* handler;
};



/**

   Prototypes
   ----------

**/


struct net_server* net_create(unsigned short port, int queue, unsigned int nthreads, req_handler* handler);
int net_delete(struct net_server* s);
int net_listen(struct net_server* s);
int net_run(struct net_server* s);


#endif
